home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Libraries / Core / Includes / UDebug.h < prev    next >
Encoding:
Text File  |  1996-04-03  |  6.4 KB  |  225 lines  |  [TEXT/MPS ]

  1. // UDebug.h
  2. // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
  3.  
  4. #ifndef __UDEBUG__
  5. #define __UDEBUG__
  6.  
  7. // MacApp
  8.  
  9. #ifndef __MACAPPTYPES__
  10. #include "MacAppTypes.h"
  11. #endif
  12.  
  13. #ifndef __UCLASSDESC__
  14. #include "UClassDesc.h"
  15. #endif
  16.  
  17. #ifndef __UITERATOR__
  18. #include "UIterator.h"
  19. #endif
  20.  
  21. // Toolbox
  22.  
  23. // ANSI
  24.  
  25. #ifndef __STDDEF__
  26. #include <stddef.h>
  27. #endif
  28.  
  29. //----------------------------------------------------------------------------------------
  30. // Forward class declarations
  31. //----------------------------------------------------------------------------------------
  32.  
  33. class CStackFrame;
  34. class TObject;
  35.  
  36.  
  37. //----------------------------------------------------------------------------------------
  38. // Procedure pointer typedefs
  39. //----------------------------------------------------------------------------------------
  40.  
  41. typedef void (*DoToFrameType)(const CStackFrame& frame, void* yourDataPtr);
  42.  
  43. #if qDebug
  44.  
  45. //----------------------------------------------------------------------------------------
  46. // class CStackFrame
  47. //----------------------------------------------------------------------------------------
  48.  
  49. class CStackFrame
  50. {
  51. private: // data fields
  52.     ptrdiff_t fFramePtr;
  53.  
  54. public: // methods
  55.     CStackFrame(void* framePtr);
  56.     CStackFrame(void);
  57.     CStackFrame(ptrdiff_t framePtr);
  58.     
  59.     CStackFrame GetCallersStackFrame() const;
  60.     
  61.     void* GetReturnAddress() const;
  62.     
  63.     const ptrdiff_t GetStackFramePtr() const;
  64.     const ptrdiff_t GetParametersPtr() const;
  65.     const short& GetParameterWord(short nthWord) const;
  66.     const long& GetParameterDoubleWord(short nthDoubleWord) const;
  67.     
  68.     const short& GetLocalWord(short nthWord) const;
  69.     const long& GetLocalDoubleWord(short nthDoubleWord) const;
  70.     
  71.     Boolean LooksValid() const;
  72.     
  73.     Boolean operator==(const CStackFrame& stackFrame) const;
  74.     Boolean operator!=(const CStackFrame& stackFrame) const;
  75. };
  76.  
  77.  
  78. //----------------------------------------------------------------------------------------
  79. // class CStackFrameIterator
  80. //----------------------------------------------------------------------------------------
  81.  
  82. class CStackFrameIterator : public CIterator
  83. {
  84. private: // data fields
  85.     CStackFrame fTopFrame;
  86.     CStackFrame fCurrentFrame;
  87.     
  88. public: // methods
  89.     CStackFrameIterator(CStackFrame topFrame);
  90.     
  91.     virtual Boolean More();
  92.         // Returns true if there are more frames to iterate over
  93.  
  94.     virtual void Reset();
  95.         // Resets the iterator to begin again
  96.     
  97.     CStackFrame FirstFrame();
  98.         // returns the first stack frame
  99.  
  100.     CStackFrame NextFrame();
  101.         // increments and then returns the current stack frame
  102.     
  103. protected: // methods
  104.     virtual void Advance();
  105.         // Advances the iteration
  106. };
  107.  
  108.  
  109. //----------------------------------------------------------------------------------------
  110. // Externally available global variables
  111. //----------------------------------------------------------------------------------------
  112.     
  113. extern Boolean gHighLevelDebuggerRunning;
  114.  
  115. #endif    // qDebug
  116.  
  117. //----------------------------------------------------------------------------------------
  118. // Externally available global flags for controlling printf info.
  119. //----------------------------------------------------------------------------------------
  120.  
  121. #if qDebug
  122. extern Boolean gUserFlag1;
  123. extern Boolean gUserFlag2;
  124. extern Boolean gUserFlag3;
  125. extern Boolean gAssumeFocused;
  126. extern Boolean gDebugPrinting;
  127. extern Boolean gIntenseDebugging;
  128. extern Boolean gReportEvent;
  129. extern Boolean gReportMenuChoices;
  130. extern Boolean gShowCursorRegion;
  131. extern Boolean gShowHelpRegion;
  132. extern Boolean gShowInvalidations;
  133. extern Boolean gShowSleepRegion;
  134. extern Boolean gMemMgtBreak;
  135. extern Boolean gRsrcReport;
  136. extern Boolean gSegReport;
  137.  
  138. // Debuggers <= kxNoDebugger don't have the ability to show debug messages in a console window
  139. // they use the AppleEvent hack for now
  140. #define kxMWDebug68K    -2
  141. #define kxMWDebugPPC    -1
  142. #define kxNoDebugger    0
  143. #define kxJasik         1
  144. #define kxSourceBug        2
  145. #define kxSade            3
  146. #define kxR2DbPPC        4
  147. #define kxR2Db68K        5
  148. #define kxVooDoo        6
  149.  
  150. extern short gCurrentDebugger;
  151. #else
  152. const Boolean gUserFlag1 = FALSE;
  153. const Boolean gUserFlag2 = FALSE;
  154. const Boolean gUserFlag3 = FALSE;
  155. const Boolean gAssumeFocused = FALSE;
  156. const Boolean gDebugPrinting = FALSE;
  157. const Boolean gIntenseDebugging = FALSE;
  158. const Boolean gReportEvent = FALSE;
  159. const Boolean gReportMenuChoices = FALSE;
  160. const Boolean gShowCursorRegion = FALSE;
  161. const Boolean gShowHelpRegion = FALSE;
  162. const Boolean gShowInvalidations = FALSE;
  163. const Boolean gShowSleepRegion = FALSE;
  164. const Boolean gMemMgtBreak = FALSE;
  165. const Boolean gRsrcReport = FALSE;
  166. const Boolean gSegReport = FALSE;
  167. #endif
  168.  
  169.  
  170. //----------------------------------------------------------------------------------------
  171. // Global function declarations
  172. //----------------------------------------------------------------------------------------
  173.  
  174. #if qDebug | qTheDebugger
  175.  
  176. extern void InitUDebug();
  177.  
  178. #endif
  179.  
  180.  
  181. #if qDebug
  182.  
  183. extern Boolean DebugCanReadLn();
  184.     // Returns true if you can ReadLn to the user. This in turn is true when there is a
  185.     // debug view (pDebugView), that view can currently write to its window, and this unit
  186.     // is initialized.
  187.  
  188. extern Boolean DebugCanWriteLn();
  189.     // Returns true if you can WriteLn to the user in the debug window. This is true if
  190.     // there exists a debug view and this unit is initialized.
  191.  
  192. extern void DebugWriteLnHook(Ptr textBuf, long byteCount);
  193.     // MacApp's bottleneck for writing debug output (not for general use). 
  194.  
  195. extern void EachFrameDo(CStackFrame baseFrame,
  196.                         DoToFrameType DoToFrame,
  197.                         void* yourDataPtr);
  198.     // Recursive iterate up the stack frame calling DoToFrame for each frame.
  199.     
  200. extern void GetCallersMethodName(MAName& s);
  201.     // Return the name of the calling method in s.
  202.  
  203. extern void GetMethodName(void* pc, MAName& s);
  204.     // Returns in s the name of the method or procedure into which address ppc points.
  205.     // Calls GetProcName to do the work.
  206.  
  207. extern void GetProcName(void* pc, ClassName& className, MAName& procName);
  208.     // Returns in procName the name of the method, procedure, or function into which
  209.     // address ppc points. If it is a method, the method's class is returned in className.
  210.     // If not a method, className is set to ''.
  211.  
  212. extern void ShowSegments();
  213.     // Write a list of the loaded segments out to the debugger.
  214.  
  215. extern Boolean System6HasDebugger();
  216.     // Check to see if Sade or SourceBug is running.  This may not work in future systems,
  217.     // so this should only be used under System 6.
  218.  
  219. extern void ConfirmHighLevelDebugger();
  220.     // Confirm that the high level debugger is still running.
  221.     
  222. #endif // qDebug
  223.  
  224. #endif // __UDEBUG__
  225.